package com.itheima.mString;

import java.util.Scanner;

/*
         键盘录入一个字符串,统计该字符串中大写字母字符,小写字母字符,数字字符出现的次数(不考虑其他字符)
 */
public class StringDemo03 {
    public static void main(String[] args) {
        //1.键盘录入一个字符串,用Scanner实现
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入:");
        String s = sc.nextLine();
        //2.要统计三种类型的字符个数,需定义三个统计量,初始值都为0
        int bigNum = 0;
        int smallNum = 0;
        int num = 0;
        //3.遍历字符串,得到每一个字符
        char[] c = s.toCharArray();
        for (int i = 0; i < c.length; i++) {
            //4.判断属于哪一种类型,然后统计变量+1
            if (c[i] >= 'A' && c[i] <= 'Z') {
                bigNum++;
            } else if (c[i] >= 'a' && c[i] <= 'z') {
                smallNum++;
            } else if (c[i] >= '0' && c[i] <= '9') {
                num++;
            }
        }
        System.out.println("bigNum" + bigNum);
        System.out.println("smallNum" + smallNum);
        System.out.println("num" + num);
    }
}
